<html>
<div id="src1">	
	#include &lt;stuff.h>
	
	//this is the test
	int test()
	{
		return 10;
	}	
	
	/* this is
	da shit!!!
	
	aye
	*/
	
	void main()
	{
		return 0;
	}
</div>


<script language="JavaScript">
	
	var hiText;
	var outputText;
	
	function highlightCppSyntax(divID)
	{
		var theDiv = document.getElementById(divID);
		
		hiText = theDiv.innerHTML;
		
		var str="";

//		while (text.length>0)
		{
			//skip spaces
			i=0;
			while ((hiText.charAt(i) == ' ')||(hiText.charAt(i) == '\t')||(hiText.charAt(i) == '\n')||(hiText.charAt(i) == '\r'))
				i++;
			str += hiText.substr(0,i);
			hiText = hiText.substr(i);
			
			//skip one-line comments
			if (hiText.substr(0,2)=='//')
			{
				i=0;
				while ((hiText.charAt(i) != '\r')&&(hiText.charAt(i) != '\n'))
					i++;
				str += "<span style='color: #00bb00;'>"+hiText.substr(0,i)+"</span>";
				hiText = hiText.substr(i);
			}
			
			//skip multi-line comments
			if (hiText.substr(0,2)=='/*')
			{
				i=0;
				while (hiText.substr(i,2) != '*/')
					i++;
				i+=2;
				str += "<span style='color: #00bb00;'>"+hiText.substr(0,i)+"</span>";
				hiText = hiText.substr(i);
			}
			
			//skip strings
			if (hiText.charAt(0)=='"')
			{
				i=1;
				while (hiText.charAt(i) != '"')
					i++;
				i++;
				str += "<span style='color: #0000ff;'>"+hiText.substr(0,i)+"</span>";
				hiText = hiText.substr(i);
			}
			
			//skip preprocessors
			if (hiText.charAt(0)=='#')
			{
				i=0;
				loop=1;
				while (loop==1)
				{
					while ((hiText.charAt(i) != '\r')&&(hiText.charAt(i) != '\n'))
						i++;
					if (text.charAt(i-1)=='\\')
						loop = 1;
					else
						loop = 0;
				}
				str += "<span style='color: #aaaaaa;'>"+hiText.substr(0,i)+"</span>";
				hiText = hiText.substr(i);
			}
			
		}		
		
		
		
		theDiv.innerHTML = "<pre>"+str+"</str>";
		theDiv.style.border= "1px solid black";
		theDiv.style.background = "#eeee00";
	}
	
	highlightCppSyntax("src1");
	
</script>
		
</html>